package org.htmlparser.util;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import org.htmlparser.Node;
import org.htmlparser.NodeFilter;
import org.htmlparser.Parser;
import org.htmlparser.Tag;
import org.htmlparser.filters.NodeClassFilter;
import org.htmlparser.filters.TagNameFilter;
import org.htmlparser.lexer.Lexer;
import org.htmlparser.lexer.Page;
import org.htmlparser.tags.CompositeTag;

public class ParserUtils
{
  private static String createDummyString(char paramChar, int paramInt)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < paramInt; ++i)
      localStringBuffer = localStringBuffer.append(paramChar);
    return new String(localStringBuffer);
  }

  public static Parser createParserParsingAnInputString(String paramString)
    throws ParserException, UnsupportedEncodingException
  {
    Parser localParser = new Parser();
    Lexer localLexer = new Lexer();
    localLexer.setPage(new Page(paramString));
    localParser.setLexer(localLexer);
    return localParser;
  }

  public static Node[] findTypeInNode(Node paramNode, Class paramClass)
  {
    NodeList localNodeList = new NodeList();
    paramNode.collectInto(localNodeList, new NodeClassFilter(paramClass));
    return localNodeList.toNodeArray();
  }

  private static NodeList getLinks(String paramString1, String paramString2, boolean paramBoolean)
    throws ParserException, UnsupportedEncodingException
  {
    new Parser();
    TagNameFilter localTagNameFilter = new TagNameFilter(paramString2);
    new NodeList();
    NodeList localNodeList = createParserParsingAnInputString(paramString1).extractAllNodesThatMatch(localTagNameFilter);
    if (!(paramBoolean))
      for (int i = 0; i < localNodeList.size(); ++i)
      {
        CompositeTag localCompositeTag1 = (CompositeTag)localNodeList.elementAt(i);
        Tag localTag1 = localCompositeTag1.getEndTag();
        int j = localCompositeTag1.getStartPosition();
        int k = localTag1.getEndPosition();
        for (int l = 0; l < localNodeList.size(); ++l)
        {
          CompositeTag localCompositeTag2 = (CompositeTag)localNodeList.elementAt(l);
          Tag localTag2 = localCompositeTag2.getEndTag();
          int i1 = localCompositeTag2.getStartPosition();
          int i2 = localTag2.getEndPosition();
          if ((l != i) && (i1 > j) && (i2 < k))
          {
            localNodeList.remove(l);
            --l;
            --i;
          }
        }
      }
    return localNodeList;
  }

  private static NodeList getLinks(String paramString, NodeFilter paramNodeFilter, boolean paramBoolean)
    throws ParserException, UnsupportedEncodingException
  {
    new Parser();
    new NodeList();
    NodeList localNodeList = createParserParsingAnInputString(paramString).extractAllNodesThatMatch(paramNodeFilter);
    if (!(paramBoolean))
      for (int i = 0; i < localNodeList.size(); ++i)
      {
        CompositeTag localCompositeTag1 = (CompositeTag)localNodeList.elementAt(i);
        Tag localTag1 = localCompositeTag1.getEndTag();
        int j = localCompositeTag1.getStartPosition();
        int k = localTag1.getEndPosition();
        for (int l = 0; l < localNodeList.size(); ++l)
        {
          CompositeTag localCompositeTag2 = (CompositeTag)localNodeList.elementAt(l);
          Tag localTag2 = localCompositeTag2.getEndTag();
          int i1 = localCompositeTag2.getStartPosition();
          int i2 = localTag2.getEndPosition();
          if ((l != i) && (i1 > j) && (i2 < k))
          {
            localNodeList.remove(l);
            --l;
            --i;
          }
        }
      }
    return localNodeList;
  }

  private static String modifyDummyString(String paramString, int paramInt1, int paramInt2)
  {
    String str = createDummyString('*', paramInt2 - paramInt1);
    return new String(paramString.substring(0, paramInt1) + str + paramString.substring(paramInt2, paramString.length()));
  }

  public static String removeChars(String paramString, char paramChar)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < paramString.length(); ++i)
    {
      char c = paramString.charAt(i);
      if (c != paramChar)
        localStringBuffer.append(c);
    }
    return localStringBuffer.toString();
  }

  public static String removeEscapeCharacters(String paramString)
  {
    return removeChars(removeChars(removeChars(paramString, '\r'), '\n'), '\t');
  }

  public static String removeTrailingBlanks(String paramString)
  {
    int i = 32;
    while (true)
    {
      do
      {
        if (i != 32)
          break label41;
        i = paramString.charAt(paramString.length() - 1);
      }
      while (i != 32);
      paramString = paramString.substring(0, paramString.length() - 1);
    }
    label41: return paramString;
  }

  public static String[] splitButChars(String paramString1, String paramString2)
  {
    label152: String[] arrayOfString;
    int i1;
    ArrayList localArrayList = new ArrayList();
    int i = 0;
    StringBuffer localStringBuffer = new StringBuffer();
    int j = 0;
    int k = 0;
    if (k < paramString1.length())
    {
      int i2 = 0;
      for (int i3 = 0; i3 < paramString2.length(); ++i3)
        if (paramString2.charAt(i3) == paramString1.charAt(k))
          i2 = 1;
      if (i2 != 0)
      {
        localStringBuffer.append(paramString1.charAt(k));
        j = 0;
        if ((j != 0) && (localStringBuffer.length() != 0))
        {
          localArrayList.ensureCapacity(++i);
          if (!(localArrayList.add(localStringBuffer.toString())))
            break label152;
          localStringBuffer = new StringBuffer();
        }
      }
      while (true)
      {
        while (true)
        {
          do
            while (true)
              ++k;
          while (j != 0);
          j = 1;
        }
        --i;
      }
    }
    if (localStringBuffer.length() != 0)
    {
      i1 = i + 1;
      localArrayList.ensureCapacity(i1);
      if (!(localArrayList.add(localStringBuffer.toString())))
        break label254;
      new StringBuffer();
    }
    while (true)
    {
      localArrayList.trimToSize();
      Object[] arrayOfObject = localArrayList.toArray();
      arrayOfString = new String[localArrayList.size()];
      int l = 0;
      while (true)
      {
        if (l >= localArrayList.size())
          break label262;
        arrayOfString[l] = new String((String)arrayOfObject[l]);
        ++l;
      }
      label254: (i1 - 1);
    }
    label262: return arrayOfString;
  }

  public static String[] splitButDigits(String paramString1, String paramString2)
  {
    label164: String[] arrayOfString;
    int i1;
    ArrayList localArrayList = new ArrayList();
    int i = 0;
    StringBuffer localStringBuffer = new StringBuffer();
    int j = 0;
    int k = 0;
    if (k < paramString1.length())
    {
      int i2 = 0;
      for (int i3 = 0; i3 < paramString2.length(); ++i3)
        if (paramString2.charAt(i3) == paramString1.charAt(k))
          i2 = 1;
      if ((Character.isDigit(paramString1.charAt(k))) || (i2 != 0))
      {
        localStringBuffer.append(paramString1.charAt(k));
        j = 0;
        if ((j != 0) && (localStringBuffer.length() != 0))
        {
          localArrayList.ensureCapacity(++i);
          if (!(localArrayList.add(localStringBuffer.toString())))
            break label164;
          localStringBuffer = new StringBuffer();
        }
      }
      while (true)
      {
        while (true)
        {
          do
            while (true)
              ++k;
          while (j != 0);
          j = 1;
        }
        --i;
      }
    }
    if (localStringBuffer.length() != 0)
    {
      i1 = i + 1;
      localArrayList.ensureCapacity(i1);
      if (!(localArrayList.add(localStringBuffer.toString())))
        break label266;
      new StringBuffer();
    }
    while (true)
    {
      localArrayList.trimToSize();
      Object[] arrayOfObject = localArrayList.toArray();
      arrayOfString = new String[localArrayList.size()];
      int l = 0;
      while (true)
      {
        if (l >= localArrayList.size())
          break label274;
        arrayOfString[l] = new String((String)arrayOfObject[l]);
        ++l;
      }
      label266: (i1 - 1);
    }
    label274: return arrayOfString;
  }

  public static String[] splitChars(String paramString1, String paramString2)
  {
    label152: String[] arrayOfString;
    int i1;
    ArrayList localArrayList = new ArrayList();
    int i = 0;
    StringBuffer localStringBuffer = new StringBuffer();
    int j = 0;
    int k = 0;
    if (k < paramString1.length())
    {
      int i2 = 0;
      for (int i3 = 0; i3 < paramString2.length(); ++i3)
        if (paramString2.charAt(i3) == paramString1.charAt(k))
          i2 = 1;
      if (i2 == 0)
      {
        localStringBuffer.append(paramString1.charAt(k));
        j = 0;
        if ((j != 0) && (localStringBuffer.length() != 0))
        {
          localArrayList.ensureCapacity(++i);
          if (!(localArrayList.add(localStringBuffer.toString())))
            break label152;
          localStringBuffer = new StringBuffer();
        }
      }
      while (true)
      {
        while (true)
        {
          do
            while (true)
              ++k;
          while (j != 0);
          j = 1;
        }
        --i;
      }
    }
    if (localStringBuffer.length() != 0)
    {
      i1 = i + 1;
      localArrayList.ensureCapacity(i1);
      if (!(localArrayList.add(localStringBuffer.toString())))
        break label254;
      new StringBuffer();
    }
    while (true)
    {
      localArrayList.trimToSize();
      Object[] arrayOfObject = localArrayList.toArray();
      arrayOfString = new String[localArrayList.size()];
      int l = 0;
      while (true)
      {
        if (l >= localArrayList.size())
          break label262;
        arrayOfString[l] = new String((String)arrayOfObject[l]);
        ++l;
      }
      label254: (i1 - 1);
    }
    label262: return arrayOfString;
  }

  public static String[] splitSpaces(String paramString1, String paramString2)
  {
    label176: String[] arrayOfString;
    int i1;
    ArrayList localArrayList = new ArrayList();
    int i = 0;
    StringBuffer localStringBuffer = new StringBuffer();
    int j = 0;
    int k = 0;
    if (k < paramString1.length())
    {
      int i2 = 0;
      for (int i3 = 0; i3 < paramString2.length(); ++i3)
        if (paramString2.charAt(i3) == paramString1.charAt(k))
          i2 = 1;
      if ((!(Character.isWhitespace(paramString1.charAt(k)))) && (!(Character.isSpaceChar(paramString1.charAt(k)))) && (i2 == 0))
      {
        localStringBuffer.append(paramString1.charAt(k));
        j = 0;
        if ((j != 0) && (localStringBuffer.length() != 0))
        {
          localArrayList.ensureCapacity(++i);
          if (!(localArrayList.add(localStringBuffer.toString())))
            break label176;
          localStringBuffer = new StringBuffer();
        }
      }
      while (true)
      {
        while (true)
        {
          do
            while (true)
              ++k;
          while (j != 0);
          j = 1;
        }
        --i;
      }
    }
    if (localStringBuffer.length() != 0)
    {
      i1 = i + 1;
      localArrayList.ensureCapacity(i1);
      if (!(localArrayList.add(localStringBuffer.toString())))
        break label278;
      new StringBuffer();
    }
    while (true)
    {
      localArrayList.trimToSize();
      Object[] arrayOfObject = localArrayList.toArray();
      arrayOfString = new String[localArrayList.size()];
      int l = 0;
      while (true)
      {
        if (l >= localArrayList.size())
          break label286;
        arrayOfString[l] = new String((String)arrayOfObject[l]);
        ++l;
      }
      label278: (i1 - 1);
    }
    label286: return arrayOfString;
  }

  public static String[] splitTags(String paramString, Class paramClass)
    throws ParserException, UnsupportedEncodingException
  {
    return splitTags(paramString, new NodeClassFilter(paramClass), true, true);
  }

  public static String[] splitTags(String paramString, Class paramClass, boolean paramBoolean1, boolean paramBoolean2)
    throws ParserException, UnsupportedEncodingException
  {
    return splitTags(paramString, new NodeClassFilter(paramClass), paramBoolean1, paramBoolean2);
  }

  public static String[] splitTags(String paramString, NodeFilter paramNodeFilter)
    throws ParserException, UnsupportedEncodingException
  {
    return splitTags(paramString, paramNodeFilter, true, true);
  }

  public static String[] splitTags(String paramString, NodeFilter paramNodeFilter, boolean paramBoolean1, boolean paramBoolean2)
    throws ParserException, UnsupportedEncodingException
  {
    ArrayList localArrayList = new ArrayList();
    new String();
    Object localObject1 = createDummyString(' ', paramString.length());
    NodeList localNodeList = getLinks(paramString, paramNodeFilter, paramBoolean1);
    int i = 0;
    if (i < localNodeList.size())
    {
      String str3;
      CompositeTag localCompositeTag = (CompositeTag)localNodeList.elementAt(i);
      Tag localTag = localCompositeTag.getEndTag();
      int i3 = localCompositeTag.getStartPosition();
      int i4 = localCompositeTag.getEndPosition();
      int i5 = localTag.getStartPosition();
      int i6 = localTag.getEndPosition();
      if (paramBoolean2)
        str3 = modifyDummyString(new String((String)localObject1), i3, i6);
      while (true)
      {
        while (true)
        {
          ++i;
          localObject1 = str3;
        }
        str3 = modifyDummyString(new String(modifyDummyString(new String((String)localObject1), i3, i4)), i5, i6);
      }
    }
    int j = ((String)localObject1).indexOf(32);
    int k = 0;
    if ((j < ((String)localObject1).length()) && (j != -1))
    {
      int i2;
      Object localObject2;
      String str2;
      int i1 = ((String)localObject1).indexOf(42, j);
      if (i1 != -1)
      {
        str2 = paramString.substring(j, i1);
        j = ((String)localObject1).indexOf(32, i1);
        i2 = k + 1;
        localArrayList.ensureCapacity(i2);
        if (localArrayList.add(str2))
          localObject2 = new String();
      }
      while (true)
      {
        String str1;
        while (true)
        {
          while (true)
          {
            while (true)
              k = i2;
            --i2;
            localObject2 = str2;
          }
          str1 = paramString.substring(j, ((String)localObject1).length());
          j = i1;
          i2 = k + 1;
          localArrayList.ensureCapacity(i2);
          if (!(localArrayList.add(str1)))
            break;
          localObject2 = new String();
        }
        --i2;
        localObject2 = str1;
      }
    }
    localArrayList.trimToSize();
    Object[] arrayOfObject = localArrayList.toArray();
    String[] arrayOfString = new String[localArrayList.size()];
    for (int l = 0; l < localArrayList.size(); ++l)
      arrayOfString[l] = new String((String)arrayOfObject[l]);
    return ((String)(String)arrayOfString);
  }

  public static String[] splitTags(String paramString, String[] paramArrayOfString)
    throws ParserException, UnsupportedEncodingException
  {
    return splitTags(paramString, paramArrayOfString, true, true);
  }

  public static String[] splitTags(String paramString, String[] paramArrayOfString, boolean paramBoolean1, boolean paramBoolean2)
    throws ParserException, UnsupportedEncodingException
  {
    ArrayList localArrayList1 = new ArrayList();
    String str1 = new String();
    String str2 = new String(paramString);
    String[] arrayOfString1 = new String[0];
    String str3 = createDummyString(' ', paramString.length());
    Object localObject1 = str1;
    int i = 0;
    Object localObject2 = localArrayList1;
    int j = 0;
    Object localObject3 = arrayOfString1;
    Object localObject4 = str2;
    while (j < paramArrayOfString.length)
    {
      NodeList localNodeList = getLinks((String)localObject4, paramArrayOfString[j], paramBoolean1);
      int k = 0;
      Object localObject5 = str3;
      if (k < localNodeList.size())
      {
        String str7;
        CompositeTag localCompositeTag = (CompositeTag)localNodeList.elementAt(k);
        Tag localTag = localCompositeTag.getEndTag();
        int i5 = localCompositeTag.getStartPosition();
        int i6 = localCompositeTag.getEndPosition();
        int i7 = localTag.getStartPosition();
        int i8 = localTag.getEndPosition();
        if (paramBoolean2)
          str7 = modifyDummyString(new String((String)localObject5), i5, i8);
        while (true)
        {
          while (true)
          {
            ++k;
            localObject5 = str7;
          }
          str7 = modifyDummyString(new String(modifyDummyString(new String((String)localObject5), i5, i6)), i7, i8);
        }
      }
      int l = ((String)localObject5).indexOf(32);
      Object localObject6 = localObject1;
      int i1 = i;
      if ((l < ((String)localObject5).length()) && (l != -1))
      {
        int i4;
        Object localObject7;
        String str6;
        int i3 = ((String)localObject5).indexOf(42, l);
        if (i3 != -1)
        {
          str6 = ((String)localObject4).substring(l, i3);
          l = ((String)localObject5).indexOf(32, i3);
          i4 = i1 + 1;
          ((ArrayList)localObject2).ensureCapacity(i4);
          if (((ArrayList)localObject2).add(str6))
            localObject7 = new String();
        }
        while (true)
        {
          String str5;
          while (true)
          {
            while (true)
            {
              while (true)
              {
                localObject6 = localObject7;
                i1 = i4;
              }
              --i4;
              localObject7 = str6;
            }
            str5 = ((String)localObject4).substring(l, ((String)localObject5).length());
            l = i3;
            i4 = i1 + 1;
            ((ArrayList)localObject2).ensureCapacity(i4);
            if (!(((ArrayList)localObject2).add(str5)))
              break;
            localObject7 = new String();
          }
          --i4;
          localObject7 = str5;
        }
      }
      StringBuffer localStringBuffer = new StringBuffer();
      ((ArrayList)localObject2).trimToSize();
      Object[] arrayOfObject = ((ArrayList)localObject2).toArray();
      String[] arrayOfString2 = new String[((ArrayList)localObject2).size()];
      for (int i2 = 0; i2 < ((ArrayList)localObject2).size(); ++i2)
      {
        arrayOfString2[i2] = new String((String)arrayOfObject[i2]);
        localStringBuffer.append(arrayOfString2[i2]);
      }
      ArrayList localArrayList2 = new ArrayList();
      String str4 = new String(localStringBuffer.toString());
      str3 = createDummyString(' ', str4.length());
      ++j;
      localObject1 = localObject6;
      i = i1;
      localObject2 = localArrayList2;
      localObject4 = str4;
      localObject3 = arrayOfString2;
    }
    return ((String)(String)(String)(String)(String)(String)localObject3);
  }

  public static String trimAllTags(String paramString, boolean paramBoolean)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    if (paramBoolean)
    {
      if ((paramString.indexOf(60) == -1) || (paramString.lastIndexOf(62) == -1) || (paramString.lastIndexOf(62) < paramString.indexOf(60)))
        localStringBuffer.append(paramString);
      while (true)
      {
        return localStringBuffer.toString();
        localStringBuffer.append(paramString.substring(0, paramString.indexOf(60)));
        localStringBuffer.append(paramString.substring(1 + paramString.lastIndexOf(62), paramString.length()));
      }
    }
    int i = 1;
    int j = 0;
    while (true)
    {
      if (j >= paramString.length());
      if ((paramString.charAt(j) == '<') && (i != 0))
        i = 0;
      if (i != 0)
        localStringBuffer.append(paramString.charAt(j));
      if ((paramString.charAt(j) == '>') && (i == 0))
        i = 1;
      ++j;
    }
  }

  public static String trimButChars(String paramString1, String paramString2)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < paramString1.length(); ++i)
    {
      int j = 0;
      for (int k = 0; k < paramString2.length(); ++k)
        if (paramString2.charAt(k) == paramString1.charAt(i))
          j = 1;
      if (j != 0)
        localStringBuffer.append(paramString1.charAt(i));
    }
    return localStringBuffer.toString();
  }

  public static String trimButCharsBeginEnd(String paramString1, String paramString2)
  {
    new String();
    int i = 0;
    int j = paramString1.length() - 1;
    int k = 1;
    for (int l = 0; (l < paramString1.length()) && (k != 0); ++l)
    {
      int i5 = 0;
      for (int i6 = 0; i6 < paramString2.length(); ++i6)
        if (paramString2.charAt(i6) == paramString1.charAt(l))
          i5 = 1;
      if (i5 != 0)
      {
        i = l;
        k = 0;
      }
    }
    int i1 = 1;
    for (int i2 = j; (i2 >= 0) && (i1 != 0); --i2)
    {
      int i3 = 0;
      for (int i4 = 0; i4 < paramString2.length(); ++i4)
        if (paramString2.charAt(i4) == paramString1.charAt(i2))
          i3 = 1;
      if (i3 != 0)
      {
        j = i2;
        i1 = 0;
      }
    }
    return paramString1.substring(i, j + 1);
  }

  public static String trimButDigits(String paramString1, String paramString2)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < paramString1.length(); ++i)
    {
      int j = 0;
      for (int k = 0; k < paramString2.length(); ++k)
        if (paramString2.charAt(k) == paramString1.charAt(i))
          j = 1;
      if ((Character.isDigit(paramString1.charAt(i))) || (j != 0))
        localStringBuffer.append(paramString1.charAt(i));
    }
    return localStringBuffer.toString();
  }

  public static String trimButDigitsBeginEnd(String paramString1, String paramString2)
  {
    new String();
    int i = 0;
    int j = paramString1.length() - 1;
    int k = 1;
    for (int l = 0; (l < paramString1.length()) && (k != 0); ++l)
    {
      int i5 = 0;
      for (int i6 = 0; i6 < paramString2.length(); ++i6)
        if (paramString2.charAt(i6) == paramString1.charAt(l))
          i5 = 1;
      if ((Character.isDigit(paramString1.charAt(l))) || (i5 != 0))
      {
        i = l;
        k = 0;
      }
    }
    int i1 = 1;
    for (int i2 = j; (i2 >= 0) && (i1 != 0); --i2)
    {
      int i3 = 0;
      for (int i4 = 0; i4 < paramString2.length(); ++i4)
        if (paramString2.charAt(i4) == paramString1.charAt(i2))
          i3 = 1;
      if ((Character.isDigit(paramString1.charAt(i2))) || (i3 != 0))
      {
        j = i2;
        i1 = 0;
      }
    }
    return paramString1.substring(i, j + 1);
  }

  public static String trimChars(String paramString1, String paramString2)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < paramString1.length(); ++i)
    {
      int j = 0;
      for (int k = 0; k < paramString2.length(); ++k)
        if (paramString2.charAt(k) == paramString1.charAt(i))
          j = 1;
      if (j == 0)
        localStringBuffer.append(paramString1.charAt(i));
    }
    return localStringBuffer.toString();
  }

  public static String trimCharsBeginEnd(String paramString1, String paramString2)
  {
    new String();
    int i = 0;
    int j = paramString1.length() - 1;
    int k = 1;
    for (int l = 0; (l < paramString1.length()) && (k != 0); ++l)
    {
      int i5 = 0;
      for (int i6 = 0; i6 < paramString2.length(); ++i6)
        if (paramString2.charAt(i6) == paramString1.charAt(l))
          i5 = 1;
      if (i5 == 0)
      {
        i = l;
        k = 0;
      }
    }
    int i1 = 1;
    for (int i2 = j; (i2 >= 0) && (i1 != 0); --i2)
    {
      int i3 = 0;
      for (int i4 = 0; i4 < paramString2.length(); ++i4)
        if (paramString2.charAt(i4) == paramString1.charAt(i2))
          i3 = 1;
      if (i3 == 0)
      {
        j = i2;
        i1 = 0;
      }
    }
    return paramString1.substring(i, j + 1);
  }

  public static String trimSpaces(String paramString1, String paramString2)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < paramString1.length(); ++i)
    {
      int j = 0;
      for (int k = 0; k < paramString2.length(); ++k)
        if (paramString2.charAt(k) == paramString1.charAt(i))
          j = 1;
      if ((!(Character.isWhitespace(paramString1.charAt(i)))) && (!(Character.isSpaceChar(paramString1.charAt(i)))) && (j == 0))
        localStringBuffer.append(paramString1.charAt(i));
    }
    return localStringBuffer.toString();
  }

  public static String trimSpacesBeginEnd(String paramString1, String paramString2)
  {
    new String();
    int i = 0;
    int j = paramString1.length() - 1;
    int k = 1;
    for (int l = 0; (l < paramString1.length()) && (k != 0); ++l)
    {
      int i5 = 0;
      for (int i6 = 0; i6 < paramString2.length(); ++i6)
        if (paramString2.charAt(i6) == paramString1.charAt(l))
          i5 = 1;
      if ((!(Character.isWhitespace(paramString1.charAt(l)))) && (!(Character.isSpaceChar(paramString1.charAt(l)))) && (i5 == 0))
      {
        i = l;
        k = 0;
      }
    }
    int i1 = 1;
    for (int i2 = j; (i2 >= 0) && (i1 != 0); --i2)
    {
      int i3 = 0;
      for (int i4 = 0; i4 < paramString2.length(); ++i4)
        if (paramString2.charAt(i4) == paramString1.charAt(i2))
          i3 = 1;
      if ((!(Character.isWhitespace(paramString1.charAt(i2)))) && (!(Character.isSpaceChar(paramString1.charAt(i2)))) && (i3 == 0))
      {
        j = i2;
        i1 = 0;
      }
    }
    return paramString1.substring(i, j + 1);
  }

  public static String trimTags(String paramString, Class paramClass)
    throws ParserException, UnsupportedEncodingException
  {
    return trimTags(paramString, new NodeClassFilter(paramClass), true, true);
  }

  public static String trimTags(String paramString, Class paramClass, boolean paramBoolean1, boolean paramBoolean2)
    throws ParserException, UnsupportedEncodingException
  {
    return trimTags(paramString, new NodeClassFilter(paramClass), paramBoolean1, paramBoolean2);
  }

  public static String trimTags(String paramString, NodeFilter paramNodeFilter)
    throws ParserException, UnsupportedEncodingException
  {
    return trimTags(paramString, paramNodeFilter, true, true);
  }

  public static String trimTags(String paramString, NodeFilter paramNodeFilter, boolean paramBoolean1, boolean paramBoolean2)
    throws ParserException, UnsupportedEncodingException
  {
    StringBuffer localStringBuffer1 = new StringBuffer();
    Object localObject1 = createDummyString(' ', paramString.length());
    NodeList localNodeList = getLinks(paramString, paramNodeFilter, paramBoolean1);
    int i = 0;
    if (i < localNodeList.size())
    {
      String str;
      CompositeTag localCompositeTag = (CompositeTag)localNodeList.elementAt(i);
      Tag localTag = localCompositeTag.getEndTag();
      int l = localCompositeTag.getStartPosition();
      int i1 = localCompositeTag.getEndPosition();
      int i2 = localTag.getStartPosition();
      int i3 = localTag.getEndPosition();
      if (paramBoolean2)
        str = modifyDummyString(new String((String)localObject1), l, i3);
      while (true)
      {
        while (true)
        {
          ++i;
          localObject1 = str;
        }
        str = modifyDummyString(new String(modifyDummyString(new String((String)localObject1), l, i1)), i2, i3);
      }
    }
    int j = ((String)localObject1).indexOf(32);
    Object localObject2 = localStringBuffer1;
    if ((j < ((String)localObject1).length()) && (j != -1))
    {
      Object localObject3;
      int k = ((String)localObject1).indexOf(42, j);
      if (k != -1)
      {
        StringBuffer localStringBuffer3 = ((StringBuffer)localObject2).append(paramString.substring(j, k));
        j = ((String)localObject1).indexOf(32, k);
        localObject3 = localStringBuffer3;
      }
      while (true)
      {
        while (true)
          localObject2 = localObject3;
        StringBuffer localStringBuffer2 = ((StringBuffer)localObject2).append(paramString.substring(j, ((String)localObject1).length()));
        j = k;
        localObject3 = localStringBuffer2;
      }
    }
    return ((String)(String)(String)((StringBuffer)localObject2).toString());
  }

  public static String trimTags(String paramString, String[] paramArrayOfString)
    throws ParserException, UnsupportedEncodingException
  {
    return trimTags(paramString, paramArrayOfString, true, true);
  }

  public static String trimTags(String paramString, String[] paramArrayOfString, boolean paramBoolean1, boolean paramBoolean2)
    throws ParserException, UnsupportedEncodingException
  {
    StringBuffer localStringBuffer1 = new StringBuffer();
    String str1 = new String(paramString);
    String str2 = createDummyString(' ', paramString.length());
    int i = 0;
    Object localObject1 = str1;
    for (Object localObject2 = localStringBuffer1; i < paramArrayOfString.length; localObject2 = localObject4)
    {
      StringBuffer localStringBuffer2 = new StringBuffer();
      NodeList localNodeList = getLinks((String)localObject1, paramArrayOfString[i], paramBoolean1);
      int j = 0;
      Object localObject3 = str2;
      if (j < localNodeList.size())
      {
        String str4;
        CompositeTag localCompositeTag = (CompositeTag)localNodeList.elementAt(j);
        Tag localTag = localCompositeTag.getEndTag();
        int i1 = localCompositeTag.getStartPosition();
        int i2 = localCompositeTag.getEndPosition();
        int i3 = localTag.getStartPosition();
        int i4 = localTag.getEndPosition();
        if (paramBoolean2)
          str4 = modifyDummyString(new String((String)localObject3), i1, i4);
        while (true)
        {
          while (true)
          {
            ++j;
            localObject3 = str4;
          }
          str4 = modifyDummyString(new String(modifyDummyString(new String((String)localObject3), i1, i2)), i3, i4);
        }
      }
      int k = ((String)localObject3).indexOf(32);
      Object localObject4 = localStringBuffer2;
      if ((k < ((String)localObject3).length()) && (k != -1))
      {
        Object localObject5;
        int l = ((String)localObject3).indexOf(42, k);
        if (l != -1)
        {
          StringBuffer localStringBuffer4 = ((StringBuffer)localObject4).append(((String)localObject1).substring(k, l));
          k = ((String)localObject3).indexOf(32, l);
          localObject5 = localStringBuffer4;
        }
        while (true)
        {
          while (true)
            localObject4 = localObject5;
          StringBuffer localStringBuffer3 = ((StringBuffer)localObject4).append(((String)localObject1).substring(k, ((String)localObject3).length()));
          k = l;
          localObject5 = localStringBuffer3;
        }
      }
      String str3 = new String((StringBuffer)localObject4);
      str2 = createDummyString(' ', str3.length());
      ++i;
      localObject1 = str3;
    }
    return ((String)(String)(String)(String)(String)((StringBuffer)localObject2).toString());
  }
}